package com.zmj.sy.mom.srv.aps.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.zmj.sy.mom.srv.aps.bean.dto.completeReport.IntegralityDto;
import com.zmj.sy.mom.srv.aps.bean.dto.completeReport.NestQgFjInfoDto;
import com.zmj.sy.mom.srv.aps.bean.dto.completeReport.OrderCompDto;
import com.zmj.sy.mom.srv.aps.bean.vo.base.BaseListResVo;
import com.zmj.sy.mom.srv.aps.bean.vo.base.BasePageResVo;
import com.zmj.sy.mom.srv.aps.bean.vo.base.Result;
import com.zmj.sy.mom.srv.aps.bean.vo.completeReport.AssemOrderVo;
import com.zmj.sy.mom.srv.aps.bean.vo.completeReport.IntegralityVo;
import com.zmj.sy.mom.srv.aps.bean.vo.completeReport.NestQgFjInfoVo;
import com.zmj.sy.mom.srv.aps.service.CompleteReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Slf4j
@RequiredArgsConstructor
@Api(tags = "齐套性监控报表")
@RestController
@RequestMapping("/completeReport")
public class CompleteReportController {

    private final CompleteReportService completeReportService;

    /**
     * @Description: 获取在产订单列表
     *
     * @author: hejiahui
     * @since: 2024/9/5 11:24
     */
    @ApiOperation(value = "1.0 获取在产订单列表", notes = "获取在产订单列表")
    @ApiOperationSupport(order = 0)
    @GetMapping(value = "/getOrderList")
    public BaseListResVo<String> getOrderList(String orderNo) {
        List<String> list = completeReportService.getOrderList(orderNo);
        return new BaseListResVo<>(list);
    }

    /**
     * @Description: 获取订单齐套性
     *
     * @author: hejiahui
     * @since: 2024/9/5 14:46
     */
    @ApiOperation(value = "1.1 获取订单齐套性", notes = "获取订单齐套性")
    @ApiOperationSupport(order = 1)
    @GetMapping(value = "/getOrderCompList")
    public BasePageResVo<AssemOrderVo> getOrderCompList(OrderCompDto dto) {
        try {
            BasePageResVo<AssemOrderVo> page = completeReportService.getAssemOrderList(dto);
            return page;
        } catch (Exception e) {
            BasePageResVo<AssemOrderVo> empty = BasePageResVo.empty();
            empty.fail("获取订单齐套性详情失败！" + e.getMessage());
            return empty;
        }
    }

    /**
     * @Description: 获取物料齐套性详情
     *
     * @author: hejiahui
     * @since: 2024/9/5 14:46
     */
    @ApiOperation(value = "1.2 获取物料齐套性详情", notes = "获取物料齐套性详情")
    @ApiOperationSupport(order = 2)
    @GetMapping(value = "/getOrderCompDetail")
    public BasePageResVo<IntegralityVo> getOrderCompDetail(IntegralityDto dto) {
        BasePageResVo<IntegralityVo> page = completeReportService.getOrderCompDetail(dto);
        return page;
    }

    /**
     * @Description: 获取零件套料，分拣，切割进度
     *
     * @author: hejiahui
     * @since: 2024/9/5 14:46
     */
    @ApiOperation(value = "1.3 获取零件套料，分拣，切割进度", notes = "获取零件套料，分拣，切割进度")
    @ApiOperationSupport(order = 2)
    @GetMapping(value = "/getNestQgFjInfo")
    public Result<List<NestQgFjInfoVo>> getNestQgFjInfo(NestQgFjInfoDto dto) {
        try {
            List<NestQgFjInfoVo> info = completeReportService.getNestQgFjInfo(dto);
            return Result.success(info);
        } catch (Exception e) {
            return Result.error(e.getMessage());
        }
    }

    /**
     * @Description: 钢板下零件切割报工记录完善
     *
     * @author: hejiahui
     * @since: 2024/9/5 11:24
     */
    @ApiOperation(value = "1.4 钢板下零件切割报工记录完善", notes = "获取在产订单列表")
    @ApiOperationSupport(order = 0)
    @PostMapping(value = "/completePlateReport")
    public Result completePlateReport(@RequestBody List<String> plateList) {
        Result result = completeReportService.completePlateReport(plateList);
        return result;
    }

}
